package com.senken.controller;

import java.lang.Thread.State;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.senken.base.BaseController;
import com.senken.service.IDeclaresService;
import com.senken.service.ITotalstateService;

@Controller
@RequestMapping("/total")
public class TotalStateController extends BaseController{

	@Autowired
	private ITotalstateService totalstateService;
	@Autowired
	private IDeclaresService declaresService;
	
	
	@RequestMapping("/counts")
	@ResponseBody
	public int counts(String fid,int state){
		return totalstateService.counts(Integer.parseInt(fid),state);
	}
	
	@RequestMapping("/changestate")
	@ResponseBody
	public Object changestate(int hid,int fid,String solution){
		if(totalstateService.updatestate(hid, fid, 2)){
			if(declaresService.finish(hid, solution)){
				return renderSuccess();
			}
		}
		return renderError("系统错误,操作未完成");
	}
}
